function login() {
    let email = $("#email_modal").val();
    let password = $("#password_modal").val();
    let data = {
        "email": email,
        "password": password//,
    }
    $.ajax({
        type: "POST", //请求的方式，默认get请求
        url: "/login", //请求地址，后台提供的
        data: JSON.stringify(data),
        contentType: 'application/json',//如果添加contentType那么传到后台的就必须是json字符串
        dataType: "json", //json格式，如果后台返回的数据为json格式的数据，那么前台会收到Object。

        success: function (result) {
            console.log(result);
            if (result.returnCode == 1) {
                window.location.href = "/test.html";
                console.log("666")
            } else {
                console.log("傻逼!你的rtnCode不是1");

            }
        }
    })
};

function Sign_up() {
    const login = document.getElementById("login");
    let name_dom = document.getElementById("sign_up1");   //用户名的dom
    let invite = document.getElementById("invite");
    let sign_input = document.getElementById("sign_up2");   //邀请码的输入
    let name = document.getElementById("name");
    let button = document.getElementById("log");    //登录按钮
    let account = document.querySelector(".account");   //用户名/邮箱的dom => 用户名
    let up = document.getElementById("up");     //注册的dom
    let submit = document.getElementById("submit");
    let blank = document.querySelector(".blank");
    name_dom.style.display = "block";
    sign_input.style.display = "block";
    name.style.display = "block";
    invite.style.display = "block";
    button.style.display = "none";
    account.innerHTML = "注册邮箱";
    up.style.display = "none";
    submit.style.display = "block";
    login.style.height = "75%";
    blank.style.marginTop = "0%";
}

function Submit() {

    let email = $("#email").val();
    let nickname = $("#name").val();
    let password = $("#password").val();
    let invite = $("#sign_up2").val();
    let data = {
        "email": email,
        "password": password,
        "nickname": nickname,
        "invite": invite
    }

    $.ajax({
        type: "POST", //请求的方式，默认get请求
        url: "/enroll", //请求地址，这里你写一个
        data: JSON.stringify(data),
        contentType: 'application/json',//如果添加contentType那么传到后台的就必须是json字符串
        dataType: "json", //json格式，如果后台返回的数据为json格式的数据，那么前台会收到Object。

        /**
         * 
         * 下面的succes回调函数你看着办，看你后端给什么数据
         */

        success: function (result) {
            //console.log(result);
            if (result.returnCode == 1) {
                window.location.href = "/login.html"
            } else {
                alert("注册失败")

            }
        }
    })
}